// 设备台账
import qs from "qs";

import request from "@/utils/request";

/**
 *GET 获取设备列表
  * @params
 * {
    "pageNumber": 0,
    "pageSize": 0,
    "type": "string",
    "deviceState": "string",
    "keywords": "string"
 * }
 * @return {*}
 */
export function getDeviceList(params) {
  return request({
    url: "/device/getList?" + qs.stringify(params),
    method: "get"
  });
}

// 获取设备信息
export function getInfo(id) {
  return request({
    url: "/device/getInfo?id=" + id,
    method: "get"
  });
}

// 获取所有设备列表
export function getAllDevice(name) {
  return request({
    url: "/device/getAll?name=" + name,
    method: "get"
  });
}

// 导出设备
export function getDeviceExport(name) {
  return request({
    url: "/device/export",
    method: "get",
    responseType: "blob"
  });
}

// 下载Excel模板
export function getDeviceTemplate(name) {
  return request({
    url: "/device/excel/template",
    method: "get",
    responseType: "blob"
  });
}

/**
 * 导入
 * @return {*}
 */
export function getDeviceImport(data) {
  return request({
    url: "/device/import",
    method: "post",
    data
  });
}

/**
 * 新增设备
 * @return {*}
 */
export function addDevice(data) {
  return request({
    url: "/device/add",
    method: "post",
    data
  });
}

/**
 * 修改设备
 * @return {*}
 */
export function updateDevice(data) {
  return request({
    url: "/device/update",
    method: "post",
    data
  });
}

/**
 * 删除设备
 * @return {*}
 */
export function deleteDeviceById(id) {
  return request({
    url: "/device/delete?id=" + id,
    method: "delete"
  });
}

/**
 * 导入设备
 * @return {*}
 */
export function importsDevice(id) {
  return request({
    url: "/device",
    method: "post"
  });
}

/**
 * 导出设备
 * @return {*}
 */
export function exportDevice(id) {
  return request({
    url: "/device",
    method: "get"
  });
}

// --------------------------------------------------------------人员台账--------------------------------------------------------------
/**
 *GET 获取用户列表
  * @params
 * {
    "pageNumber": 0,
    "pageSize": 0,
    "type": "string",
    "deviceState": "string",
    "keywords": "string"
 * }
 * @return {*}
 */
export function getUserList(params) {
  return request({
    url: "/user/getList?" + qs.stringify(params),
    method: "get"
  });
}

/* 获取所有用户列表
state  人员状态 0在岗 1休假 2离岗
keywords */
export function getUserAll(params) {
  return request({
    url: "/user/getAll?" + qs.stringify(params),
    method: "get"
  });
}

// 导出人员
export function getUserExport() {
  return request({
    url: "/user/export",
    method: "get",
    responseType: "blob"
  });
}

/**
 * 添加人员台账
 * @return {*}
 */
export function addUserLedger(data) {
  return request({
    url: "/user/add",
    method: "post",
    data
  });
}

/**
 * 更新用户
 * @return {*}
 */
export function updateUserLedger(data) {
  return request({
    url: "/user/update",
    method: "post",
    data
  });
}

/**
 * 删除用户台账
 * @return {*}
 */
export function deleteUserLedgerById(id) {
  return request({
    url: "/user/delete?id=" + id,
    method: "delete"
  });
}

// /**
//  * 导入设备
//  * @return {*}
//  */
// export function importsUserLedger(id) {
//   return request({
//     url: "/user",
//     method: "post",
//   })
// }

/**
 * 导出设备
 * @return {*}
 */
export function exportUserLedger(id) {
  return request({
    url: "/user",
    method: "get"
  });
}

// --------------------------------------------------------------  备件台账  --------------------------------------------------------------
/**
 *GET 获取备件列表
  * @params
 * {
    "pageNumber": 0,
    "pageSize": 0,
    "type": "string",
    "deviceState": "string",
    "keywords": "string"
 * }
 * @return {*}
 */
export function getPartList(params) {
  return request({
    url: "/part/getList?" + qs.stringify(params),
    method: "get"
  });
}

// 获取所有备件列表
export function getPartAll(name = "") {
  return request({
    url: "/part/getAll?name=" + name,
    method: "get"
  });
}

// 导出备件
export function getPartExport(name) {
  return request({
    url: "/part/export",
    method: "get",
    responseType: "blob"
  });
}

/**
 * 添加备件台账
 * @return {*}
 */
export function addPartLedger(data) {
  return request({
    url: "/part/add",
    method: "post",
    data
  });
}

/**
 * 更新备件
 * @return {*}
 */
export function updatePartLedger(data) {
  return request({
    url: "/part/update",
    method: "post",
    data
  });
}

/**
 * 删除备件台账
 * @return {*}
 */

export function deletePartLedgerById(id) {
  return request({
    url: "/part/delete?id=" + id,
    method: "delete"
  });
}
